<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	 <base href="<%=basePath%>">
	
		<link href="themes/css/ui.common.css" rel="stylesheet"
			type="text/css" />
		<link href=" themes/css/ui.child.css" rel="stylesheet"
			type="text/css" />
		<link href=" themes/css/ui.tips.css" rel="stylesheet"
			type="text/css" />
		<script src=" Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src=" Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src=" Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script src=" Scripts/ui.tips.js" type="text/javascript"></script>
		<script src=" Scripts/ui.default.js " type="text/javascript"
			charset="UTF-8"></script>
		<link id="skin_css" rel="stylesheet" type="text/css"
			href=" themes/css/ui.c.blue.css"></link>
		<STYLE type="text/css">
.editorArea{
	display: none;
}
</STYLE>
		<script type="text/javascript">
		//鼠标点击的时候,出现编辑框,回车可以提交请求
		$(function(){
			$(".textPanel").click(function(){
			     var __id = $(this).attr("oid");
			     $("#sender_"+__id).click();
			     $("#editor_"+__id).focus();
			  });
		   $(".textBox").keydown(function(e){ 
		      
          		if(e.keyCode==13){ 
           			$("#sender_"+$(this).attr("oid")).click();//处理事件 
       			} 
          });  
		
		});
	function showEditor(id)
	{
	   var content = $("#content_"+id);
	   var editorArea = $("#editorArea_"+id);
	   var editor = $("#editor_"+id);
	   editor.val(content.text());
	   
	   editorArea.show();  
		
	   $("#switcher_"+id).attr("src"," themes/icons/ok.png").attr("title","提交");
	   content.hide(); 
	}
	
	function hideEdit(id,withSubmit)
	{
	   var content = $("#content_"+id);
	   var editorArea = $("#editorArea_"+id);
	   var editor = $("#editor_"+id);
	   editorArea.hide();   
	  var text = editor.val();
	  
	   //显示原内容。。 
       
       if(withSubmit==true){
         if(content.text()!= text)
         { 
          
                $.post("newsCategory!modify.action", 
               		{"categoryId":id,"categoryName":text},
                		 function (data) {  
                        }, 
              		     "json"); 
         }
        //
        content.text(text);
       } 
       $("#switcher_"+id).attr("src"," themes/icons/edit.png").attr("title","进行编辑");
        content.show();
	}
	
	function switchSave(id,withSubmit)
	{  
	 var ___id= "#sender_"+id ;
	  var sender= $(___id); 
	   var stateCode = sender.attr("state"); 
	   if(stateCode==0 || stateCode==undefined)
	   { 
	     // 进行保存 。 
	     $(sender).attr("state",1);  
	     showEditor(id); 
	
	   }
	   if(stateCode==1)
	   { 
	     $(sender).attr("state",0);
	     $("#submitting").show();
	     hideEdit(id,withSubmit);  
	   }
	}

     function cancelSave(id,withSubmit)
     {
         switchSave(id,false);
          
     }
 

</script>
	</head>

	<body>
<div class="PageChild_Title">
			<img src=" themes/images/default/icons/archives.png" class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText"><h2>新闻类型</h2></span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
		</div>
		<div class="PageChild_Where">
			<table style="height: 60px;" border="0" cellpadding="0"
				cellspacing="0">
				 
				 
				<tr>
					<td class="mtd" valign="top">
						类型名称:
					</td>
					<td>
						<input name="txt_Tile" type="text" maxlength="100" id="add"
							style="width: 200px;" />
							&nbsp;<input type="button" value="添加" onclick='var text= $("#add").val();if($.trim(text).length==0){alert("请输入名称.");$("#add").focus(); return false;} location="newsCategory!add.action?categoryName="+text'/>
							
					
					</td>
				</tr>
				 
				<tr>
					<td>&lsquo;&rsquo;
					</td>
					<td>
						<s:if test="count!=null">
						<span id="lbl_list_count">共搜索到 <b>${count}</b> 条符合条件的记录。</span>
						</s:if> 
					</td>
				</tr>
			</table>
		</div>
		<div class="PageChild_List">
			<table width="100%" border="0" cellspacing="0"
				style="text-align: left">
				<tbody class="PageChild_List_head">
					<tr>
						<td width="16">
							<img src=" themes/images/default/icons/pcde_314.png" width="16"
								height="16" />
						</td>
						<td>
							名称
						</td>
						<td class="td_width40">
							编辑
						</td>
						<td class="td_width40">
							删除
						</td>
					</tr>
				</tbody>
				<tbody class="PageChild_List_main" style="text-align: left">

					<s:iterator value="list" var="item">
						<!-- 新闻类型列表开始 -->
						<tr class='td_no_bord'>
							<td class="td_width25">
								<span title="24"><input id="Chk_Num" type="checkbox"
										name="ReptShow$ctl01$Chk_Num" /> </span>
							</td>
							<td title="单击内容进行编辑.回车提交更新.">
								<span oid="${item.categoryId}" class="textPanel" id="content_${item.categoryId}"> ${item.categoryName} </span>
								<div id="editorArea_${item.categoryId}" class="editorArea">
									<input id="editor_${item.categoryId}" class="textBox" type="text"
										size="50" maxlength="40" oid="${item.categoryId}" />
								</div>
							</td>
							<td>
								<a class="editButton" id="sender_${item.categoryId}"
									href="javascript:void(0);" state="0"
									onclick="switchSave(${item.categoryId},true);"> <img
										id="switcher_${item.categoryId}"
										src=" themes/icons/edit.png" title="进行编辑" /> </a> &nbsp;
								 
							</td>
							<td>
								<a href="javascript:;" onclick='location="newsCategory!delete.action?categoryId=${item.categoryId}"'><img
										src=" themes/icons/delete.png" /> </a>
							</td>
						</tr>
					</s:iterator>
					<!-- 新闻列表结束 -->
				</tbody>
			</table>
			 
		</div>
		
	</body>
</html>
